package com.platform.data.handle.converter;

import com.platform.data.common.CommonConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 数据类型转处理接口
 *
 * @author zhuweijun
 * @version 1.0.0
 * @since 2025/5/13 13:19
 */
public abstract class AbstractDataTypeProcessHandler {

    protected static final Logger log = LoggerFactory.getLogger(AbstractDataTypeProcessHandler.class);

    /**
     * 默认匹配冒号：中英文
     */
    protected static final Pattern colonPattern = Pattern.compile(CommonConstant.DEFAULT_COLON_REGEX);
    /**
     * 校验整数
     */
    protected static final Pattern integerPattern = Pattern.compile(CommonConstant.DEFAULT_INTEGER_REGEX);

    /**
     * 处理数据
     *
     * @param typeEnum typeEnum
     * @param fieldName fieldName
     * @param fieldValue fieldValue
     * @return {@link Object}
     */
    public abstract Object process(DataTypeEnum typeEnum, String fieldName, String fieldValue);

    /**
     * 正则匹配冒号（中英文）
     *
     * @param pattern pattern
     * @param value value
     * @return {@link Matcher}
     */
    public Matcher matcherValue(Pattern pattern, String value) {
        Matcher matcher = pattern.matcher(value);
        if(matcher.find()){
            return matcher;
        }
        return null;
    }

}
